<?php
    // Bible verse save
    // @author: trungdt
    // @since Aug 3

    if (!defined("EXPONENT")) exit("");
    global $user;
    if (exponent_users_isAdmin() &&  isset($_REQUEST['book']) && isset($_REQUEST['chapter']) && isset($_REQUEST['translation']) && isset($_REQUEST['verse']))
    {
        $translation = intval($_REQUEST['translation']);
        // get translation short name
        $bible=$db->selectObject("bibles","id = " . $translation);
        if ($bible == null) 
        {
            die();
        }
        else
        {
            $short_name = $bible->short_name;
            $book=intval($_REQUEST['book']); $chapter=intval($_REQUEST['chapter']);
            $verse=intval($_REQUEST['verse']);
            
            $bibletext=$_POST['bibletext'];
            $search_text = strip_tags($bibletext);
            
            $sql="UPDATE {$db->prefix}bible_{$short_name} SET bibletext='{$bibletext}', search_text = \"{$search_text}\" WHERE book = {$book} AND chapter={$chapter} AND verse={$verse}";
            $db->sql($sql);
            
            exponent_flow_redirect();
        }
    }



?>